#!/usr/bin/bash

# TODO: required=TRUE should not be required
# https://github.com/rstudio/reticulate/issues/791

export TF_CPP_MIN_LOG_LEVEL=2
  # 0 = all messages are logged (default behavior)
  # 1 = INFO messages are not printed
  # 2 = INFO and WARNING messages are not printed
  # 3 = INFO, WARNING, and ERROR messages are not printed


for i in 2.{6..8}
# for i in 2.{4..7} nightly
# for i in 2.{1..3}
do
TMPDIR="/tmp/r-keras-tests/tf-$i/"
mkdir -p $TMPDIR
rsync -a --delete . $TMPDIR
gnome-terminal --title="keras test: tf $i" --working-directory=$TMPDIR -- \
  Rscript -e "{options(error=recover); cat('\n\n\n'); Sys.unsetenv('RETICULATE_PYTHON'); reticulate::use_miniconda('tf-$i-cpu', required=TRUE); devtools::test(); cat('Done!')}"
  # Rscript -e "{cat('\n\n\n'); }"
  # ; scan('stdin',  nlines=1)
done
